package com.ssy.lingxi.enhance.entity;


import com.ssy.lingxi.enhance.handler.convert.JpaJsonToManualDeliverBOConverter;
import com.ssy.lingxi.enhance.handler.convert.JpaJsonToMapConverter;
import com.ssy.lingxi.enhance.model.bo.ManualDeliverBO;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.*;
import java.io.Serializable;
import java.util.HashMap;

/**
 * 生产通知单 - DO
 * @author fhj
 * @date 2020/10/15
 * @version 2.0.0
 */
@Data
@Entity
@Table(schema = "public", name = "enhance_produce_notice_order", indexes = {
        @Index(name = "enhance_produce_notice_order_notice_no_idx", columnList = "noticeNo"),
        @Index(name = "enhance_produce_notice_order_supplier_member_id_idx", columnList = "supplierMemberId"),
        @Index(name = "enhance_produce_notice_order_supplier_role_id_idx", columnList = "supplierRoleId"),
        @Index(name = "enhance_produce_notice_order_process_member_id_idx", columnList = "processMemberId"),
        @Index(name = "enhance_produce_notice_order_process_role_id_idx", columnList = "processRoleId")
})
public class ProduceNoticeOrderDO implements Serializable {
    private static final long serialVersionUID = 5680922571290422867L;

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "produce_notice_order_seq")
    @SequenceGenerator(sequenceName = "enhance_produce_notice_order_seq", name = "produce_notice_order_seq", allocationSize = 1)
    @ApiModelProperty(value = "ID")
    private Long id;

    @Column(columnDefinition = "varchar(20)")
    @ApiModelProperty(value = "通知单号")
    private String noticeNo;

    @Column(columnDefinition = "varchar(60)")
    @ApiModelProperty(value = "通知单摘要")
    private String summary;

    @Column(columnDefinition = "int8")
    @ApiModelProperty(value = "供应商会员ID")
    private Long supplierMemberId;

    @Column(columnDefinition = "int8")
    @ApiModelProperty(value = "供应商会员角色ID")
    private Long supplierRoleId;

    @Column(columnDefinition = "varchar(50)")
    @ApiModelProperty(value = "供应商会员名称")
    private String supplierName;

    @Column(columnDefinition = "int8")
    @ApiModelProperty(value = "加工企业会员ID")
    private Long processMemberId;

    @Column(columnDefinition = "int8")
    @ApiModelProperty(value = "加工企业会员角色ID")
    private Long processRoleId;

    @Column(columnDefinition = "varchar(50)")
    @ApiModelProperty(value = "加工企业会员名称")
    private String processName;

    @Column(columnDefinition = "int2")
    @ApiModelProperty(value = "通知单来源: 1-订单加工 2-商品加工")
    private Integer source;

    @Column(columnDefinition = "numeric")
    @ApiModelProperty(value = "加工费")
    private Double processTotalPrice;

    @Column(columnDefinition = "int8")
    @ApiModelProperty(value = "交期")
    private Long deliveryDate;

    @Column(columnDefinition = "int2")
    @ApiModelProperty(value = "配送方式: 1-物流 2-自提")
    private Integer deliveryType;

    @Column(columnDefinition = "int8")
    @ApiModelProperty(value = "收货地址id")
    private Long receiverAddressId;

    @Column(columnDefinition = "varchar(100)")
    @ApiModelProperty(value = "收货地址")
    private String receiveAddress;

    @Column(columnDefinition = "varchar(50)")
    @ApiModelProperty(value = "收货人姓名")
    private String receiveUserName;

    @Column(columnDefinition = "varchar(16)")
    @ApiModelProperty(value = "收货人电话")
    private String receiveUserTel;

    @Column(columnDefinition = "int8")
    @ApiModelProperty(value = "发货地址id")
    private Long deliveryAddressId;

    @Column(columnDefinition = "varchar(100)")
    @ApiModelProperty(value = "发货地址")
    private String deliveryAddress;

    @Column(columnDefinition = "varchar(50)")
    @ApiModelProperty(value = "发货人姓名")
    private String deliveryUserName;

    @Column(columnDefinition = "varchar(16)")
    @ApiModelProperty(value = "发货人电话")
    private String deliveryUserTel;

    @Convert(converter = JpaJsonToManualDeliverBOConverter.class)
    @Column(columnDefinition = "jsonb")
    @ApiModelProperty(value = "手工发货信息")
    private ManualDeliverBO manualDeliver;

    @Convert(converter = JpaJsonToMapConverter.class)
    @Column(columnDefinition="jsonb")
    @ApiModelProperty(value = "通知单其他要求(交付说明, 付款说明, 税费说明, 物流说明, 包装说明, 其他说明, 附件名称, 附件地址)")
    private HashMap<String, Object> otherAsk;

    @Column(columnDefinition = "varchar(255)")
    @ApiModelProperty("原因")
    private String cause;

    @Column(columnDefinition = "int4")
    @ApiModelProperty(value = "发货批次")
    private Integer deliveryBatch = 0;

    @Column(columnDefinition = "int8")
    @ApiModelProperty(value = "发货单id")
    private Long deliveryId;

    @Column(columnDefinition = "varchar(50)")
    @ApiModelProperty(value = "发货单号")
    private String deliveryNo;

    @Column(columnDefinition = "int8")
    @ApiModelProperty(value = "入库单id")
    private Long storageId;

    @Column(columnDefinition = "varchar(50)")
    @ApiModelProperty(value = "入库单号")
    private String storageNo;

    @Column(columnDefinition = "int8")
    @ApiModelProperty(value = "物流单ID")
    private Long logisticsOrderId;

    @Column(columnDefinition = "varchar(50)")
    @ApiModelProperty(value = "物流单号")
    private String logisticsOrderNo;

    @Column(columnDefinition = "int8")
    @ApiModelProperty(value = "中止时间")
    private Long discontinueTime;

    @Column(columnDefinition = "int8")
    @ApiModelProperty(value = "创建时间")
    private Long createTime = System.currentTimeMillis();

    @Column(columnDefinition = "int4")
    @ApiModelProperty(value = "状态")
    private Integer status;

    @Column(columnDefinition = "int4")
    @ApiModelProperty(value = "供应商内部状态")
    private Integer supplierInnerStatus;

    @Column(columnDefinition = "int4")
    @ApiModelProperty(value = "加工企业内部状态")
    private Integer processInnerStatus;

    @Column(columnDefinition = "int4")
    @ApiModelProperty(value = "外部状态")
    private Integer outerStatus;

    @Column(columnDefinition = "varchar(50)")
    @ApiModelProperty(value = "供应商内部任务ID")
    private String supplierInnerTaskId;

    @Column(columnDefinition = "varchar(50)")
    @ApiModelProperty(value = "加工企业内部任务ID")
    private String processInnerTaskId;

    @Column(columnDefinition = "varchar(50)")
    @ApiModelProperty(value = "外部任务ID")
    private String outerTaskId;

    @Column(columnDefinition = "varchar(255)")
    @ApiModelProperty(value = "供应商内部工作流key")
    private String supplierInnerProcessKey;

    @Column(columnDefinition = "varchar(255)")
    @ApiModelProperty(value = "加工企业内部工作流key")
    private String processInnerProcessKey;

    @Column(columnDefinition = "varchar(255)")
    @ApiModelProperty(value = "外部工作流key")
    private String outerProcessKey;

    @Column(columnDefinition = "int4")
    @ApiModelProperty(value = "供应商内部工作流类型")
    private Integer supplierInnerTaskType;

    @Column(columnDefinition = "int4")
    @ApiModelProperty(value = "加工企业内部工作流类型")
    private Integer processInnerTaskType;

    @Column(columnDefinition = "int4")
    @ApiModelProperty(value = "外部工作流类型")
    private Integer outerTaskType;

    @Column(columnDefinition = "int2")
    @ApiModelProperty(value = "是否异常：0-否 1-是")
    private Integer error = 0;
}
